{% extends 'dashboard.html' %}

{% block content %}
 <div class="right_col" role="main">
          <div class="">

            <div class="col-md-12 col-sm-12 col-xs-12">
                <div class="x_panel">
                  <div class="x_title">
                    <h2>人员管理</h2>
                      <ul class="nav navbar-right panel_toolbox">
                          <li><button type="button" class="btn btn-success btn-sm" onclick="{location.href='{{ url_for('user_create') }}'}">新增+</button></li>
                      </ul>
                    <div class="clearfix"></div>
                  </div>
                  <div class="x_content">

                    <table id="datatable-buttons" class="table table-striped table-bordered">

                      <thead>
                        <tr>
                          <th>用户名</th>
                          <th>角色</th>
                          <th>邮箱</th>
                          <th>操作</th>
                        </tr>
                      </thead>


                      <tbody>
                      {% for user in users %}
                        <tr>
                          <td>{{ user.name }}</td>
                          <td>{% if user.role == 'dev' %}开发人员{% elif user.role == 'audit' and user.srole == 0 %}主审核人{% elif user.role == 'audit' and user.srole == 1 %}副审核人{% endif %}</td>
                          <td>{{ user.email }}</td>
                          <td>
                              {% if user.role == 'audit' and user.srole == 0 %}<button type="button" class="btn btn-warning btn-sm" onclick="{location.href='{{ url_for('user_srole',id=user.id) }}'}">设置为副审核</button>{% elif user.role == 'audit' and user.srole == 1 %}<button type="button" class="btn btn-warning btn-sm" onclick="{location.href='{{ url_for('user_srole',id=user.id) }}'}">设置为主审核</button>{% endif %}
                              {% if user.role == 'dev' %}<button type="button" class="btn btn-primary btn-sm" onclick="{location.href='{{ url_for('user_db_alloc',id=user.id) }}'}">分配数据库</button>{% endif %}
                              <button type="button" class="btn btn-info btn-sm" onclick="{location.href='{{ url_for('user_update',id=user.id) }}'}">修改</button>
                              <button type="button" class="btn btn-danger btn-sm" onclick="javascript:if (confirm('确定要删除?')) location.href='{{ url_for('user_delete',id=user.id) }}';">删除</button></td>
                        </tr>
                      {% endfor %}

                      </tbody>
                    </table>
                  </div>
                </div>
              </div>

          </div>
        </div>
        <!-- /page content -->
{% endblock %}